﻿using System;
using System.Collections.Generic;
using System.Web.UI;
using visinia.SmartEngine;
using visinia.SmartEngine.Installer;
using visinia.SmartEngine.Modules;
using visinia.SmartEngine.SiteMap;

public partial class Modules_General_SiteMap : WebModule
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected override void WebModuleRender(HtmlTextWriter output)
    {
        output.Write("<h2>Sitemap</h2>");
        ModuleInfo module = ModuleController.GetModule(ModuleId);
        foreach (Plugin plugin in PluginController.GetInstalledPlugins())
        {
            List<SiteMapInfo> list = SiteMapController.GetPluginSiteMapData().FindAll(p => string.Compare(p.Plugin, plugin.Name, true) == 0);
            if (list == null)
                continue;
            if (list.Count == 0)
                continue;
            List<string> text = new List<string>();
            List<string> links = new List<string>();
            foreach (SiteMapInfo sitemapInfo in list)
            {
                text.Add(sitemapInfo.Title);
                links.Add(sitemapInfo.Url);
            }
            string data = WebHelpers.GenerateBulletedListHyperLinks(text.ToArray(), links.ToArray());
            if (text.Count > 0)
            {
                output.Write("<h3>" + plugin.Name + "</h3>");
                output.Write(data);
            }
        }
    }

}